package com.bum.guru.baucua.service;

import org.apache.commons.lang.StringUtils;

import com.bum.api.core.exp.IApiService;
import com.bum.api.core.exp.om.Metas;
import com.bum.api.core.exp.om.Params;
import com.bum.guru.baucua.bo.BauCuaJsonBO;

public class BauCuaJsonService implements IApiService {
	BauCuaJsonBO	bauCuaJsonBO;

	enum Func {
		req,
		commit
	}

	public void setBauCuaJsonBO(BauCuaJsonBO bauCuaJsonBO) {
		this.bauCuaJsonBO = bauCuaJsonBO;
	}

	@Override
	public String getJson(String path, Params params, Metas metas) {
		String[] parts = StringUtils.split(path, "/", 2);

		Func func = null;
		if (parts.length > 0) {
			func = Func.valueOf(parts[0]);
			switch (func) {
				case req:
					return bauCuaJsonBO.request(null, params, metas);

				case commit:
					/**
					 * baucua/commit
					 */
					return bauCuaJsonBO.commit(null, params, metas);

				default:
					break;
			}
		}

		return null;
	}

	@Override
	public String getHtml(String path, Params params, Metas metas) {
		return null;
	}

	@Override
	public String getPage(String path, Params params, Metas metas) {
		return null;
	}

}
